package com.friday.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.friday.bo.PersonnelBo;
import com.friday.bo.impl.PersonnelBoImpl;
import com.sun.net.ssl.internal.ssl.Debug;

public class AddEmployeeServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("AddEmployeeServlet");
		String name = request.getParameter("name");
		String password = request.getParameter("password");
		String account = request.getParameter("account");
		String dep = request.getParameter("bumen");
		int actor = Integer.parseInt(request.getParameter("zhiwei"));
		
		System.out.println(name +","+ password +","+ account +","+ dep +","+ actor);
		
		PersonnelBo personnelBo = new PersonnelBoImpl();
		try {
			personnelBo.addEmployee(name, account, password, actor, dep);
		} catch (Exception e) {
			e.printStackTrace();
		}
		response.sendRedirect("GetAllEmployeesServlet.do");
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
